package com.glory.good_dark.adapter;

import android.view.View;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.good_dark.R;
import com.glory.good_dark.activity.CapacityMangerActivity;

import java.util.List;

/**
 * FileName: CapacityMangerListAdapter
 * Author: XJH
 * Date: 2020/9/17 10:10
 * Description:
 * History:
 */
public class CapacityMangerListAdapter extends BaseQuickAdapter<CapacityMangerActivity.PersonBindInfoEntity.PersonEqp, BaseViewHolder> {
    private OnDeleteListener mListener;

    public CapacityMangerListAdapter(@Nullable List<CapacityMangerActivity.PersonBindInfoEntity.PersonEqp> data) {
        super(R.layout.adapter_capacity_manger,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CapacityMangerActivity.PersonBindInfoEntity.PersonEqp item) {
        helper.setText(R.id.tvEqpID,item.getEQP_ID());
        helper.getView(R.id.tvUnBind).setOnClickListener(v -> {
            if (mListener != null){
                mListener.onDelete(item,helper.getAdapterPosition());
            }
        });
    }

    public interface OnDeleteListener{
        void onDelete(CapacityMangerActivity.PersonBindInfoEntity.PersonEqp item,int position);
    }

    public void setOnDeleteListener(OnDeleteListener listener){
        this.mListener = listener;
    }
}
